package models;

import play.*;
import play.db.jpa.*;

import javax.persistence.*;

import java.util.*;

@Entity
public class RequestOfCommListCreator extends Model {

	/** Nada El-Sherief */
	public long recieverId;
	/** Nada El-Sherief */
	public long senderId;
	/** Nada El-Sherief */
	public long commListId;
	/** Nada El-Sherief */
	public boolean sent;
	/** Nada El-Sherief */
	public boolean isAccepted = false;
	/** Nada El-Sherief */
	public boolean isRejected = false;
	/** Nada El-Sherief */
	@ManyToMany(mappedBy = "requestsToCreatorCommList", cascade = CascadeType.ALL)
	public List<RegisteredUser> creatorRequests;
	/**
	 * getter for isAccepted attribute
	 * 
	 * @author Nada
	 * @return boolean
	 */

	public boolean isAccepted() {
		return isAccepted;
	}

	/**
	 * setter for isAccepted attribute
	 * 
	 * @author Nada
	 * @param isAccepted
	 * 
	 */
	public void setAccepted(boolean isAccepted) {
		this.isAccepted = isAccepted;
	}

	/**
	 * getter for isRejected attribute
	 * 
	 * @author Nada
	 * @return boolean
	 */

	public boolean isRejected() {
		return isRejected;
	}

	/**
	 * setter for isRejected attribute
	 * 
	 * @author Nada
	 * @param isRejected
	 * 
	 */

	public void setRejected(boolean isRejected) {
		this.isRejected = isRejected;
	}

	public boolean isSent() {
		return sent;
	}

	public long getRecieverId() {
		return recieverId;
	}

	/**
	 * setter for recieverId attribute
	 * 
	 * @author Nada
	 * @param recieverId
	 * 
	 */
	public void setRecieverId(long recieverId) {
		this.recieverId = recieverId;
	}

	public long getSenderId() {
		return senderId;
	}

	/**
	 * setter for senderId attribute
	 * 
	 * @author Nada
	 * @param senderId
	 * 
	 */
	public void setSenderId(long senderId) {
		this.senderId = senderId;
	}

	public long getCommListId() {
		return commListId;
	}

	/**
	 * setter for commListId attribute
	 * 
	 * @author Nada
	 * @param commListId
	 * 
	 */

	public void setCommListId(long commListId) {
		this.commListId = commListId;
	}

	/**
	 * setter for sent attribute
	 * 
	 * @author Nada
	 * @param sent
	 * 
	 */

	public void setSent(boolean sent) {
		this.sent = sent;
		this.save();
	}

	/**
	 * getter for creatorRequests attribute
	 * 
	 * @author Nada list of creator requests of a user
	 */

	public List<RegisteredUser> getCreatorRequests() {
		return creatorRequests;
	}

	/**
	 * setter for creatorRequests attribute
	 * 
	 * @author Nada
	 * @param creatorRequests
	 * 
	 */

	public void setCreatorRequests(List<RegisteredUser> creatorRequests) {
		this.creatorRequests = creatorRequests;

	}


	public RequestOfCommListCreator(long recieverId, long senderId,
			long commListId) {
		this.recieverId = recieverId;
		this.senderId = senderId;
		this.commListId = commListId;
		this.sent = false;
		this.isAccepted = false;
		this.isRejected = false;
		this.save();
	}
}
